package com.ccb.jyzx.expand.tiantouonline.service.impl;

import com.ccb.jyzx.expand.tiantouonline.bean.vo.PageBean;
import com.ccb.jyzx.expand.tiantouonline.service.PageService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ProjectName: extend
 * @Author: jianghaolin
 * @Version: 1.0
 */
@Service
public class PageServiceImpl implements PageService {

    private static int totalPage = 0;

    @Override
    public PageBean getPage(int currPage, int pageSize, int totalCount, List lists) {
        int current = totalCount % pageSize;
        int totalPages = totalCount / pageSize;
        if(current == 0){
            totalPage = totalPages;
        }else{
            totalPage =  totalPages + 1;
        }
        PageBean pageBean = new PageBean();
        pageBean.setCurrPage(currPage);
        pageBean.setLists(lists);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalCount(totalCount);
        pageBean.setTotalPage(totalPage);
        return pageBean;
    }
}
